#include<bits/stdc++.h>
using namespace std;
int n;
char path[19];
bool pd[19];
void dfs(int x){
    if(x == n){
        for(int i = 1; i <= n; i ++) cout << path[i];
        cout << endl;
        return;
    }
    for(int i = 1; i <= n; i ++){//对称
        if(!pd[i]){
            path[x] = i;
            pd[i] = 1;
            dfs(x + 1);
            pd[i] = 0;//恢复现场
        }
    }
}
int main(){
    cin >> n;
    dfs(0);
    return 0;
}